﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<a href="<%=Url.Action("index","inbox") %>"><img src='<%=Url.Content("~/Content/letter.png") %>' alt='inbox' /><div id="messageCount" class='fr'>
    </div></a>
    <br />
<script type="text/javascript">

    $(function () {
        sync();       
        setInterval("sync()", 60000);
    });

    function sync() {
        $.post('<%=Url.Action("GetNewMessages","sync") %>', function (d) {
            if(d.Count != 0) $('#messageCount').html(d.Count + " mesaje necititie");
            $.each(d.List, function (i, v) {
                $('body').append('<div id="notify' + i + '">' + v.Subject + '</div>');
                $('#notify' + i).dialog({ position: ['right', 'bottom'], title:'mesaj nou' });
            });
        });
    }
</script>
